package cn.yuanqiao.archive.statistics.service.impl;

import cn.yuanqiao.archive.statistics.domain.StatisticalConfiguration;
import cn.yuanqiao.archive.statistics.mapper.StatisticalConfigurationMapper;
import cn.yuanqiao.archive.statistics.service.IStatisticalConfigurationService;
import cn.yuanqiao.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 年报统计配置Service业务层处理
 * 
 * @author xy
 * @date 2023-07-31
 */
@Service
public class StatisticalConfigurationServiceImpl implements IStatisticalConfigurationService 
{
    @Autowired
    private StatisticalConfigurationMapper statisticalConfigurationMapper;

    /**
     * 查询年报统计配置
     *
     * @param id 年报统计配置主键
     * @return 年报统计配置
     */
    @Override
    public StatisticalConfiguration selectStatisticalConfigurationById(Long id,String type)
    {

        return statisticalConfigurationMapper.selectStatisticalConfigurationById(new StatisticalConfiguration().getTableName(),type);
    }

    /**
     * 查询年报统计配置列表
     *
     * @param statisticalConfiguration 年报统计配置
     * @return 年报统计配置
     */
    @Override
    public List<StatisticalConfiguration> selectStatisticalConfigurationList(StatisticalConfiguration statisticalConfiguration)
    {
        return statisticalConfigurationMapper.selectStatisticalConfigurationList(statisticalConfiguration);
    }

    /**
     * 新增年报统计配置
     *
     * @param statisticalConfiguration 年报统计配置
     * @return 结果
     */
    @Override
    public int insertStatisticalConfiguration(StatisticalConfiguration statisticalConfiguration)
    {
        statisticalConfiguration.setCreateId(SecurityUtils.getUserId());
        statisticalConfigurationMapper.deleteStatisticalConfiguration(statisticalConfiguration.getTableName(),statisticalConfiguration.getType());
        return statisticalConfigurationMapper.insertStatisticalConfiguration(statisticalConfiguration);
    }

    /**
     * 修改年报统计配置
     *
     * @param statisticalConfiguration 年报统计配置
     * @return 结果
     */
    @Override
    public int updateStatisticalConfiguration(StatisticalConfiguration statisticalConfiguration)
    {
        return statisticalConfigurationMapper.updateStatisticalConfiguration(statisticalConfiguration);
    }

    /**
     * 批量删除年报统计配置
     *
     * @param ids 需要删除的年报统计配置主键
     * @return 结果
     */
    @Override
    public int deleteStatisticalConfigurationByIds(Long[] ids)
    {
        return statisticalConfigurationMapper.deleteStatisticalConfigurationByIds(ids);
    }

    /**
     * 删除年报统计配置信息
     *
     * @param id 年报统计配置主键
     * @return 结果
     */
    @Override
    public int deleteStatisticalConfigurationById(Long id)
    {
        return statisticalConfigurationMapper.deleteStatisticalConfigurationById(id);
    }
}
